﻿Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Xml.Linq
Imports Exp.Model
Imports Exp.DATA_Service

Public Class Site
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            If Session("USER") Is Nothing Then
                Response.Redirect("~/login.aspx")
            Else
                Dim objUser As REM_User = CType(Session("USER"), REM_User)
                If Not objUser Is Nothing Then
                    RenderMenu(objUser.Role_ID)
                End If

                lblUserFullName.Text = objUser.TitleName.ToString.Trim & objUser.FirstName.ToString.Trim & " " & objUser.LastName.ToString.Trim
                lblUserRole.Text = objUser.REM_Role.RoleName.ToString()

            End If
            
        End If
    End Sub

    Private Sub RenderMenu(p1 As Byte)
        Select Case p1
            Case 1
                AdminMenu.Visible = True

            Case 2
                ApproverMenu.Visible = True
                BookingListMenu.Visible = True
            Case 3
                OwnerMenu.Visible = True
                BookingListMenu.Visible = True
        End Select
    End Sub

    Protected Sub lnkLogout_Click(sender As Object, e As EventArgs)
        Session("USER") = Nothing
        Session.Clear()
        Response.Redirect("~/login.aspx")
    End Sub

    

End Class

